package com.company.behavioral.memento_pattern.originator;

import com.company.behavioral.memento_pattern.memento.ChessmanMemento;

/**
 * 象棋棋子
 * @ClassName Chessman
 * @Author tiezheng.han
 * @Date 2020/9/4 18:11
 **/
public class Chessman {

    private String lable;
    private int x;
    private int y;

    public Chessman(String lable, int x, int y) {
        this.lable = lable;
        this.x = x;
        this.y = y;
    }

    public String getLable() {
        return lable;
    }

    public void setLable(String lable) {
        this.lable = lable;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    /**
     * 保存状态
     * @return
     */
    public ChessmanMemento save(){
        return new ChessmanMemento(this.lable,this.x,this.y);
    }

    public void restore(ChessmanMemento memento){
        this.lable = memento.getLable();
        this.x = memento.getX();
        this.y = memento.getY();

    }
}
